package com.frxuexi.park2305.news

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.NewsBeanItem
import com.frxuexi.park2305.R
import com.frxuexi.park2305.databinding.ItemNews2Binding
import com.frxuexi.park2305.databinding.ItemNewsBinding

class NewsAdapter:BaseMultiItemQuickAdapter<NewsBeanItem,BaseViewHolder>() {
    init {
        addItemType(0,R.layout.item_news)
        addItemType(1,R.layout.item_news2)
    }

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemNewsBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: NewsBeanItem) {
        if(item.mytype==0){
            DataBindingUtil.getBinding<ItemNewsBinding>(helper.itemView)?.bean=item
        }else{
            DataBindingUtil.getBinding<ItemNews2Binding>(helper.itemView)?.bean=item
        }
    }
}